/******************************************************************************
 * Copyright (C) 2015  671643387@qq.com
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 *****************************************************************************/

#ifndef SYSTEM_THREAD_H_
#define SYSTEM_THREAD_H_

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif

#include "Ucop/Macros.h"
#ifdef _WIN32
#include "Ucop/System/Thread_WIN32.h"
#else
#error
#endif


namespace Ucop {
namespace System {
    class Runnable;

    class Thread: private ThreadImpl
    {
    public:
        /* Thread priority */
        enum Priority
        {
            PRIO_LOWEST = PRIO_LOWEST_IMPL,
            PRIO_LOW = PRIO_LOW_IMPL,
            PRIO_NORMAL = PRIO_NORMAL_IMPL,
            PRIO_HIGH = PRIO_HIGH_IMPL,
            PRIO_HIGHEST = PRIO_HIGHEST_IMPL
        };
        /* Thread ID */
        typedef ThreadImpl::ID	ID;

        Thread(Runnable *_Runnable) : ThreadImpl(_Runnable) {}
        ~Thread(void) {}


        bool Start(void) { return StartImpl(); }
        void Join(void) { JoinImpl(); }
        bool Joinable(void) { return JoinableImpl(); }
        bool SetPriority(int priority) { return SetPriorityImpl(priority); }
        ID GetID(void) const { return GetIDImpl(); }

        static ID GetCurrentID(void) { return GetCurrentIDImpl(); }
        static void Sleep(long _Miliseconds) { SleepImpl(_Miliseconds); }


    private:
        DISALLOW_COPY_AND_ASSIGN(Thread);
    };

}}

#endif // SYSTEM_THREAD_H_
